import java.util.Arrays;
import java.util.Scanner;

public class demo01 {
//    递增三元组
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i]=sc.nextInt();
        }
        int[] b=new int[n+1];
        for (int i = 1; i <= n; i++) {
            b[i]=sc.nextInt();
        }
        int[] c=new int[n+1];
        for (int i = 1; i <= n; i++) {
            c[i]=sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long count=0;
        for (int i = 1,index1=1,index3=1; i <= n; i++) {
            while (index1<=n&&a[index1]<b[i]){
                index1++;
            }
            while (index3<=n&&c[index3]<=b[i]){
                index3++;
            }
            count+=(long)(index1-1)*(n-index3+1);
        }
        System.out.println(count);
    }
}
